home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Unix / ftpget.shar / ftpget < prev   
Encoding:
Text File  |  1993-05-21  |  1.1 KB  |  57 lines

  1. #!/local/bin/perl
  2. # ftpget. (C) S.Maffeis 1992. maffeis@ifi.unizh.ch
  3.  
  4. require 'ftp.pl';
  5.  
  6. sub usage{
  7.   print STDERR 
  8.     "usage: ftpget remotehost [username passwd] remotefile localfile\n";
  9. };
  10.  
  11. if(scalar(@ARGV) != 3 && scalar(@ARGV) != 5){ &usage(); exit 1;};
  12.  
  13. if(scalar(@ARGV) == 3){
  14.   chop($hostname = `/bin/hostname`);
  15.   
  16.   if(!&ftp'open(@ARGV[0], 21, 0, 1)){
  17.     print STDERR "cannot open connection to @ARGV[0]\n";
  18.     exit 1;
  19.   };
  20.   if(!&ftp'login("anonymous", "ftpget@$hostname")){
  21.     print STDERR "cannot login as anonymous\n";
  22.     exit 1;
  23.   };
  24.   if( ! &ftp'type('I')){
  25.     print STDERR "cannot set file type to I\n";
  26.     exit 1;
  27.   };
  28.   if(!&ftp'get(@ARGV[1], @ARGV[2])){ 
  29.     print STDERR "@ARGV[1]: file not found\n";
  30.     exit 1;
  31.   };
  32.   &ftp'quit();
  33.   
  34.   exit 0;
  35. };
  36.  
  37. if(!&ftp'open(@ARGV[0], 21, 1, 1)){
  38.   print STDERR "cannot open connection to @ARGV[0]\n";
  39.   exit 1;
  40. };
  41. if(!&ftp'login(@ARGV[1], @ARGV[2])){
  42.   print STDERR "cannot login as @ARGV[1]\n";
  43.   exit 1;
  44. };
  45. if( ! &ftp'type('I')){
  46.   print STDERR "cannot set file type to I\n";
  47.   exit 1;
  48. };
  49. if(!&ftp'get(@ARGV[3], @ARGV[4])){
  50.   print STDERR "@ARGV[3]: file not found\n";
  51.   exit 1;
  52. };
  53. &ftp'quit();
  54.  
  55. exit 0;
  56.  
  57.